//Some sort of basic javascript library
//TODO: check IE compability
Lib = {

    //Makes an AJAX request
    makeRequest : function(url, func, args, type, context) {
        var rtype = type || "POST";
        var http_request = false;
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
            }
        }
        else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
        if (!http_request) {
            return false;
        }
        http_request.onreadystatechange = function() { 
            func.call(context, http_request); 
        };
        if (rtype == "GET" && args.length) 
            url += '?' + args;
        http_request.open(rtype, url, true);
        if (rtype == "POST") {
            http_request.setRequestHeader("Content-Type",
                "application/x-www-form-urlencoded; charset=utf-8");
            http_request.setRequestHeader("Content-Length", args.length);
        }
        http_request.setRequestHeader("Accept-Charset","utf-8;q=1");
        if (args.length > 0)
          http_request.send(args);
        else
          http_request.send(null);
    },

    //get element by it's id
    getElementById : function(elementId) {
        return document.getElementById(elementId);
    }
};
